package example.array;

/**
 * Created by lenovo on 2016/11/4 0004.
 * 通过数组的length属性，获取数组长度
 */
public class ArrayLength {
    public static void main(String[] args) {
        String[][] data = new String[2][5];
        data[0][0] = "hello";
        for (int i = 0; i < data.length; i++) {
            for (int j = 0; j < data[i].length; j++) {
                data[i][j] = "i:" + i + "j " + j;
            }
        }
        /**
         * 二维数组类似于
         * data =
         * [0,1]
         * [1,1]
         * [2,2]
         * [3,3]
         * [4,4]
         */
        System.out.println("第一维数组长度：" + data.length);
        System.out.println("第二维数组长度：" + data[0].length);

        for (String[] i : data) {
            for (String s : i) {
                System.out.println(s);
            }
        }
    }
}
